﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AntUnion.FrameWork.Util
{
    public class HtmlUtil
    {
        public static string ReplaceHtmlTag(string html, int length = 0)
        {
            try
            {
                if(string.IsNullOrEmpty(html))
                {
                    return "";
                }
                string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");

                if (length > 0 && strText.Length > length)
                    return strText.Substring(0, length);

                return strText;
            }
            catch (Exception)
            {
                throw;
            }
      
        }
    }
}
